num=str(input())
num=num.split()
spis=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
chislo=''
for i in num:
    for j in range(len(spis)):
        if i == spis[j]:
            chislo+=str(j)
chislo=int(chislo)

prost=[]
for i in range(100,1000):
    count=0
    for j in range(2,i//2+1):
        if i%j==0:
            count+=1
    if count==0:
        prost.append(i)
print(prost)
for i in range(len(prost)):
    if prost[i]<=chislo<=prost[i+1]:
        if prost[i+1]- chislo>=chislo-prost[i]:
                print(prost[i])
        else:
            print(prost[i+1])
    if chislo==100 or chislo==101:
        print('101')
        break
    if chislo==998 or chislo==999 or chislo ==997:
        print('997')
        break
        